#include "led.h"

#include "FreeRTOS.h"
#include "task.h"

#include "driverlib/i2c.h"

#include "mySerial/mySerial.h"

/**
 * @brief    LED_Task 任务函数
 * @brief    闪烁灯，体现程序正常跑了
 */
void LED_Task(void *pvParameters)
{
  while (1)
  {
    LED0_RGB_B_DISABLE;
    LED0_RGB_R_ENABLE;
    vTaskDelay(500);
    LED0_RGB_R_DISABLE;
    LED0_RGB_G_ENABLE;
    vTaskDelay(500);
    LED0_RGB_G_DISABLE;
    LED0_RGB_B_ENABLE;
    vTaskDelay(500/portTICK_RATE_MS);
  }
}

void LED_Init(void)
{
  LED0_RGB_Init();
}

void LED0_RGB_Init(void)
{
  // Enable the GPIO port
  SysCtlPeripheralEnable(LED0_RGB_R_GPIOPERIPH);
  SysCtlPeripheralEnable(LED0_RGB_G_GPIOPERIPH);
  SysCtlPeripheralEnable(LED0_RGB_B_GPIOPERIPH);
  // Enable the GPIO pins
  GPIOPinTypeGPIOOutput(LED0_RGB_R_GPIO, LED0_RGB_R_PIN);
  GPIOPinTypeGPIOOutput(LED0_RGB_G_GPIO, LED0_RGB_G_PIN);
  GPIOPinTypeGPIOOutput(LED0_RGB_B_GPIO, LED0_RGB_B_PIN);

  // 关闭所有灯
  LED0_RGB_R_DISABLE;
  LED0_RGB_G_DISABLE;
  LED0_RGB_B_DISABLE;

  // 创建 LED_Task 任务
  xTaskCreate(LED_Task, "LED_Task", 128, NULL, 3, NULL);
}
